<template>
  <div>
    <!-- group -->
    <van-cell-group>
      <!-- group-header -->
      <van-cell>
        <template #title>
          <span class="custom-title">外卖订单:{{ orderList.orderId }}</span>
        </template>
        <template #value>
          <span class="greyText" v-if="orderList.is_pay">已完成</span>
          <span v-else>
            <span class="greyText" v-if="orderList.is_not">已取消</span>
            <span class="text_2480X1" v-else>待付款</span>
          </span>
        </template>
      </van-cell>
      <!-- group-content -->
      <van-cell>
        <template #title>
          <span class="text_2481X1" @click="jumpOrderPage(orderList)" >{{ orderList.address }}</span>
        </template>
        <template #value>
          <span class="text_2483X1">{{ orderList.time }}</span>

          <span class="btn">
            <span v-if="orderList.is_pay">
              <van-button type="default" size="small" class="btn1"
                >再来一单</van-button
              >
              <van-button
                plain
                type="primary"
                size="small"
                @click="goComment(orderList.id)"
                v-if="orderList.is_comment"
                >去评价</van-button
              >
            </span>

            <van-button plain type="warning" size="small" v-else
              >去支付</van-button
            >
          </span>
        </template>
        <template #label>
          <span class="text_2482X1">{{ orderList.goods }}等 共1件商品</span>
          <span class="text_2484X1">¥{{ orderList.goods_price }}</span>
        </template>
      </van-cell>
    </van-cell-group>
  </div>
</template>

<script setup>
import router from "@/router";
import { useOrderList } from '@/hooks/order/useOrder'
// 引入hooks方法
const { jumpOrderPage } =useOrderList()
const props = defineProps({
  orderList: {
    id: {
      type: String,
      required: true,
    },
    address: {
      type: String,
      required: true,
    },
    goods: {
      type: String,
      required: true,
    },
    goods_price: {
      type: Number,
      required: true,
    },
    is_comment: {
      type: Boolean,
      required: true,
    },
    is_pay: {
      type: Boolean,
      required: true,
    },
    is_not: {
      type: Boolean,
      required: true,
    },
    time: {
      type: String,
      required: true,
    },
  },
});
const goComment = (id) => {
  router.push({
    path: "/order/comment",
    query: {
      id,
    },
  });
};
</script>

<style lang="scss" scoped>
.van-cell-group {
  margin-top: 15px;
  .custom-title {
    display: inline-block;
    width: 180px;
    height: 19px;
    left: 15px;
    top: 127px;
    color: rgba(166, 166, 166, 1);
    font-size: 12px;
    line-height: 150%;
    text-align: left;
  }
  .text_2480X1 {
    width: 39px;
    height: 19px;
    left: 321px;
    top: 121px;
    color: rgba(136, 175, 213, 1);
    font-size: 12px;
    line-height: 150%;
    text-align: left;
  }
  .text_2481X1 {
    display: inline-block;
    height: 22px;
    left: 15px;
    top: 169px;
    color: rgba(56, 56, 56, 1);
    font-size: 14px;
    line-height: 150%;
    text-align: left;
    font-weight: bold;
    width: 190px;
    white-space: nowrap;
    overflow: hidden; //文本超出隐藏
    text-overflow: ellipsis; //文本超出省略号替代
  }
  .text_2483X1 {
    width: 103px;
    height: 18px;
    left: 257px;
    top: 171px;
    color: rgba(166, 166, 166, 1);
    font-size: 12px;
    line-height: 150%;
    text-align: left;
  }
  .text_2482X1 {
    width: 135px;
    height: 19px;
    left: 15px;
    top: 194px;
    color: rgba(80, 80, 80, 1);
    font-size: 13px;
    line-height: 150%;
    text-align: left;
    display: block;
  }
  .greyText {
    color: grey;
    font-size: 12px;
  }
  .text_2484X1 {
    display: block;
    width: 23px;
    height: 21px;
    left: 15px;
    top: 238px;
    color: rgba(56, 56, 56, 1);
    font-size: 14px;
    line-height: 150%;
    text-align: left;
    font-weight: bold;
    margin-top: 30px;
  }
  .btn {
    display: block;
    margin-top: 50px;
    .btn1 {
      margin-right: 5px;
    }
  }
}
</style>